Skip to content

GraalVM support#2740

Merged
riccardobl merged 15 commits into
jMonkeyEngine:masterfrom
riccardobl:graal
May 12, 2026
Merged

GraalVM support#2740
riccardobl merged 15 commits into
jMonkeyEngine:masterfrom
riccardobl:graal

Conversation

@riccardobl
Copy link
Copy Markdown
Member

@riccardobl riccardobl commented May 5, 2026

While JME is already technically compatible with GraalVM, most of the setup required to make it work has historically been left to application developers, this pr fixes that:

  • GraalVM becomes a detectable platform
  • Reachability metadata are automatically generated via classpath and bytecode scanning and added to the artifacts
  • The native library loader supports a "non-extraction" mode where it loads natives pre-extracted to a specific directory
  • TestChooserCLI is an alternative test chooser that runs in the commandline without AWT, to avoid carrying over the big AWT libraries and to avoid known bugs in macos when awt is mixed with opengl contexts.
  • A reusable gradle plugin that when added to a gradle project, automatically extends the reachability metadata to the project codebase and handles native libraries extraction and launch flags when a native image is built

To test:

./gradlew :jme3-examples:nativeCompile
./jme3-examples/build/native/nativeCompile/jme3-testchooser
# or on windows:
# ./jme3-examples/build/native/nativeCompile/jme3-testchooser.exe 

Build your jme project with graalvm

Add (no configuration needed)

plugins {
    id 'org.jmonkeyengine.nativeimage' version '3.10.0-SNAPSHOT'
}

run ./gradlew nativeCompile

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

🖼️ Screenshot tests have failed.

The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests.

📄 Where to find the report:

⚠️ If you didn't expect to change anything visual:
Fix your changes so the screenshot tests pass.

If you did mean to change things:
Review the replacement images in jme3-screenshot-tests/build/changed-images to make sure they really are improvements and then replace and commit the replacement images at jme3-screenshot-tests/src/test/resources.

If you are creating entirely new tests:
Find the new images in jme3-screenshot-tests/build/changed-images and commit the new images at jme3-screenshot-tests/src/test/resources.

Note; it is very important that the committed reference images are created on the build pipeline, locally created images are not reliable. Similarly tests will fail locally but you can look at the report to check they are "visually similar".

See https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-screenshot-tests/README.md for more information

Contact @richardTingle (aka richtea) for guidance if required

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant updates to the Android support, including a migration to AndroidX Fragments, improved GraalVM native-image support, and enhancements to the renderer's handling of sRGB and mipmap generation. I have reviewed the changes and provided feedback regarding the abrupt process termination in the error dialog and a potential logic issue in the buffer update loop.

Comment thread jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java
Comment thread jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java
@riccardobl riccardobl marked this pull request as ready for review May 10, 2026 14:48
@riccardobl
Copy link
Copy Markdown
Member Author

@gemini-code-assist please review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive support for GraalVM Native Image across the engine. Key changes include a new Gradle script for automated reachability metadata generation, runtime detection of GraalVM/Native Image environments in the Platform class, and automatic configuration of native library paths for LWJGL and SaferAllocator. Additionally, a CLI-based test chooser is implemented to bypass AWT/Swing limitations in native executables. Review feedback suggests improving the test chooser by replacing reflection with direct API calls for LegacyApplication, adding timeouts to busy-wait loops to prevent indefinite hangs, and implementing error handling or fallbacks for symbolic link creation on Windows systems.

Comment thread jme3-examples/src/main/java/jme3test/TestChooserCli.java Outdated
Comment thread jme3-examples/src/main/java/jme3test/TestChooserCli.java Outdated
Comment thread jme3-examples/build.gradle Outdated
@riccardobl
Copy link
Copy Markdown
Member Author

@gemini-code-assist review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive support for GraalVM Native Image. It adds a specialized Gradle script for generating reachability metadata, implements runtime environment detection in the Platform class, and provides configurable native library extraction. A new TestChooserCli is added to facilitate running examples in headless native environments. Review feedback suggests enhancing the class file parser to support Java 11+ dynamic constants, ensuring file streams are correctly closed, and improving the safety of JAR file system access to avoid exceptions.

Comment thread jme3-examples/src/main/java/jme3test/TestChooserCli.java Outdated
@riccardobl riccardobl marked this pull request as draft May 11, 2026 13:09
@riccardobl riccardobl marked this pull request as ready for review May 11, 2026 18:46
Comment thread jme3-desktop/src/test/java/com/jme3/system/NativeLibraryLoaderTest.java Outdated
Comment thread jme3-examples/src/main/java/jme3test/TestChooserCli.java Outdated
@riccardobl riccardobl merged commit 72f7aae into jMonkeyEngine:master May 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant